package com.example.a.service;

import com.example.a.dao.DepartmentMapper;
import com.example.a.feign.ServiceBFeignClient;
import com.example.a.feign.ServiceCFeignClient;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
@RequiredArgsConstructor
public class DepartmentService {

    private final DepartmentMapper departmentDao;
    private final ServiceBFeignClient serviceBFeignClient;
    private final ServiceCFeignClient serviceCFeignClient;

//    @Transactional
    @GlobalTransactional
    public void delete(Long id) {
        if (id != 1L) {
            log.debug("示例代码参数逻辑错误，已经修正为 1 。");
            id = 1L;
        }
        departmentDao.deleteById(id);

        serviceBFeignClient.delete(2L);
        serviceCFeignClient.delete(3L);
    }
}
